<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="content" style="width: 80%;height: 800px;padding: 10px 40px;color: green;font-size: 20px;">

</div>
<script>
  var source = new EventSource("/api/ArticleTitle/getTitle?key_word=西红柿&generated_quantity=30&event_name=test&key=641821c6d4979" );
  //监听test事件
  source.addEventListener('test', function (event) {
    console.log(event)
    console.log(event.data)
    if(event.data) {
        if(event.data=== 'end'){
            source.close()
        }else{
            let res = JSON.parse(event.data)
            let content = document.getElementById('content');
            content.innerHTML = content.innerHTML +  '<br/>' + res.title
        }
    }

  });
</script>
</body>
</html>
